<?php

if(Yii::app()->user->hasFlash('model')) {
	Yii::app()->user->flash('model', array('<div class="confirmation">', '</div>'));
	echo "</div>";
	return;
}

?>

<h2>Account Settings</h2>
<div class="yiiForm">
<?php
$this->breadcrumbs=array(
	Yii::t('yii','Profile')
);

$JFV=Yii::app()->jformvalidate;
$JFV->setOptions(array(
		'errorElement'=> 'div',
		'errorClass' => 'invalid',
        ));

echo $JFV->form('', 'post', array('autocomplete'=>'off','enctype'=>'multipart/form-data'));
?>

<?php echo Html::errorSummary($user); ?>

<div class="simple">
<?php echo Html::activeLabel($user,'email'); ?>
<?php echo $JFV->activeTextField($user,'email'); ?>
<p class="hint">Note: If you change your email address you will be immediately logged out and will not be able to log back in until you revalidate your email address.</p>
</div>

<div class="simple">
<?php echo Html::activeLabel($user,'about'); ?>
<?php echo $JFV->activeTextArea($user,'about'); ?>
<p class="hint">This will appear on your user page.<br />
You may enter content using <?php echo EHtml::link('Markdown syntax', 'http://daringfireball.net/projects/markdown/syntax', array('target'=>'_blank'))?>.
</p>
</div>

<div class="simple">
<?php echo Html::activeLabel($user,'website'); ?>
<?php echo $JFV->activeTextField($user,'website'); ?>
<p class="hint">Write it as http://example.com This may be your personal website, blog or something that you find interesting.</p>
</div>

<div class="simple">
<img src="<?php echo Yii::app()->request->baseUrl; ?>/images/avatars/<?php echo $user->image; ?>" alt="logo" id="comapnylogo" style="margin-left:110px;margin-bottom:20px;"/>
<br/>
<?php echo Html::activeLabel($user,'logo'); ?>
<?php echo Html::activeFileField($user,'logo'); ?>
<p class="hint">If you have Gglobally recognized avatar from <a title="Gravatar" href="http://gravatar.com/" target="_blank">gravatar.com</a> it will be used as your default avatar.
.</p>
</div>

<div class="simple">
<?php echo Html::activeLabel($user,'password'); ?>
<?php echo $JFV->activePasswordField($user,'password', array('value'=>'')); ?>
</div>
<div class="simple">
<?php echo Html::activeLabel($user,'password_repeat'); ?>
<?php echo $JFV->activePasswordField($user,'password_repeat', array('value'=>'')); ?>
</div>

<div class="simple">
<?php echo Html::activeLabel($user,'email_visible'); ?>
<?php echo Html::activeCheckBox($user,'email_visible'); ?>
</div>

<div class="simple">
<?php echo Html::activeLabel($user,'notify_comments'); ?>
<?php echo Html::activeCheckBox($user,'notify_comments'); ?>
</div>

<div class="simple">
<?php echo Html::activeLabel($user,'notify_messages'); ?>
<?php echo Html::activeCheckBox($user,'notify_messages'); ?>
</div>
<?php if (Yii::app()->user->hasAuth(Group::ADMIN)) { ?>
<div class="simple">
<?php echo Html::activeLabel($user, 'group_id'); ?>
<?php echo Html::activeDropDownList($user, 'group_id', EHtml::listData(Group::model()->getListed(), 'id', 'name')); ?>
</div>
<?php } ?>
<div class="action">
<?php echo Html::submitButton('Save'); ?>
</div>

<?php echo $JFV->endForm(); ?>
</div><!-- yiiForm -->

<script type="text/javascript">
$("form").bind("submit", function() { return false; });

$('.submit').bind('click', function () {
  jQuery.ajax({
'type':'POST',
'dataType' : 'html',
'url': jQuery(this).parents("form").attr("action"),
'cache':false,
'data':jQuery(this).parents("form").serialize(),
'success':function(html){
jQuery("#content").html(html)}
});
  return false;
});

</script>
